package io.jnet.client.clientchannelcontext;

import java.nio.channels.AsynchronousSocketChannel;
import java.util.concurrent.ExecutorService;
import io.jnet.common.api.ReadHandler;
import io.jnet.common.api.impl.TaskAttachReadHandler;
import io.jnet.common.bufstorage.BufStorage;
import io.jnet.common.businessprocessor.TaskAttachProcessor;
import io.jnet.common.decodec.FrameDecodec;
import io.jnet.common.streamprocessor.StreamProcessor;
import io.jnet.common.util.AioListener;

public class TaskAttachClientChannelContext extends AbstractClientChannelContext
{
    private ReadHandler readHandler;
    
    public TaskAttachClientChannelContext(//
            ExecutorService executorService, //
            int maxMerge, //
            BufStorage bufStorage, //
            StreamProcessor[] outProcessors, //
            AsynchronousSocketChannel socketChannel, //
            AioListener clientListener, //
            StreamProcessor[] inProcessors, //
            FrameDecodec frameDecodec)
    {
        super(maxMerge, bufStorage, outProcessors, socketChannel, clientListener, inProcessors, frameDecodec);
        TaskAttachProcessor taskAttachProcessor = new TaskAttachProcessor(this, bufStorage, writeHandler, inProcessors, executorService, clientListener);
        readHandler = new TaskAttachReadHandler(taskAttachProcessor, socketChannel, frameDecodec, ioBuf, clientListener, this);
    }
    
    @Override
    public void registerRead()
    {
        readHandler.registerRead();
    }
    
}
